package com.az.usr.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.az.miaoapi.exception.BaseException;
import com.az.miaoapi.exception.ReTryException;
import com.az.miaoapi.response.ResponseCode;
import com.az.servicecommon.domain.Vo;
import com.az.servicecommon.util.BaseResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.retry.annotation.Retryable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

@BaseResponse
@RestController
@RequestMapping("/usr")
@RequiredArgsConstructor
@Retryable(retryFor = ReTryException.class)
public class TestController {
    @PostMapping
    @SentinelResource("usr")
    public Vo test(Principal principal) {
        System.out.println("hello usr");
        throw new BaseException(ResponseCode.SERVICE_ERROR);
    }
}
